<template>
  <HelloWorld msg="Vue 3 + TypeScript + Vite" msg2="这是msg2" @onCtoF = "receiveResult"/>

  <p>子组件向父组件传值：{{ c_to_f }}</p>
  <p>{{ count }}</p>
  <button @click="handleAdd">+1</button>
  <br/>
  <br/>

  <OnePage></OnePage>

  <ContextPage/>

  <hr />

  <WatchPage></WatchPage>

  <el-button type="primary"> elementButton</el-button>

</template>

<script lang="ts">
import {defineComponent, ref, reactive, computed, onMounted, provide, getCurrentInstance} from 'vue'
import HelloWorld from './components/HelloWorld.vue'
import OnePage from "./OnePage.vue";
import ContextPage from "./ContextPage.vue"
import WatchPage from "./WatchPage.vue";

export default defineComponent({
  name: 'App',
  components: {
    WatchPage,
    OnePage,
    HelloWorld,
    ContextPage
  },
  setup() {
    //定义响应式的变量；set，get 需要使用 count.value 属性
    const count = ref(0)

    const msg = ref<String>("sdfsd")

    const obj = reactive({
      title:"这是title"
    })

    provide('title',"这是title")

    const handleAdd = () => {
      count.value = count.value + 1;
    }

    const c_to_f = ref<Number>(0)

    const receiveResult = (value: Number) => {
      console.log(value)
      c_to_f.value = value
    }

    onMounted(() => {
      console.log('onMounted')
    })


    console.log(getCurrentInstance()?.appContext.config.globalProperties.Utils.plus(1,43))


    return {
      count,
      handleAdd,
      c_to_f,
      receiveResult

    }
  },
})
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
  font-size: x-large;
}
</style>
